/**
 * This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
 */
package com.softwarecraftsmen.cachecontrol;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.jetbrains.annotations.NotNull;

public class IsSame<T> extends BaseMatcher<T>
{
	private final T expectedIdentity;

	public IsSame(@NotNull final T expectedIdentity)
	{
		this.expectedIdentity = expectedIdentity;
	}

	public boolean matches(final Object item)
	{
		return item == expectedIdentity;
	}

	public void describeTo(final Description description)
	{
		description.appendText("an identity (an identical reference)");
	}

	@Factory
	public static <T> IsSame<T> isSame(@NotNull final T expectedIdentity)
	{
		return new IsSame<T>(expectedIdentity);
	}
}
